﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Pgcommon.Modules.gznr;

namespace Pgcommon
{
    public partial class FrmMain : DevExpress.XtraEditors.XtraForm
    {
        public FrmMain()
        {
            InitializeComponent();
            this.MdiChildActivate += FrmMain_MdiChildActivate;
        }

        void FrmMain_MdiChildActivate(object sender, EventArgs e)
        {
            ActiveForm();
        }

        private void FrmMain_Load(object sender, EventArgs e)
        {
            LoadForm(new FrmWelcome());
        }

        private void LoadForm(Form frm)
        {
            var frms = this.MdiChildren;

            if (frms.Any(o => o.Name.Equals(frm.Name)))
            {
                frms.Single(o => o.Name.Equals(frm.Name)).Activate();

                frm.Dispose();
            }
            else
            {
                frm.MdiParent = this;

                frm.Tag = this;

                frm.Show();
            }
        }

        private void xtraTabbedMdiManager1_SelectedPageChanged(object sender, EventArgs e)
        {
           
        }



        public void ActiveForm()
        {
            //if (this.ActiveMdiChild!=null)
            //{ 
            //string activform = this.ActiveMdiChild.Name;

            //if (activform == "FrmWelcome")
            //{
            //    ribbonPage1.Visible = false;
            //}
            //}
        }

        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (e.Node.Text == "人员")
            {
                LoadForm(new listRenyuan());
            }
        }
    }
}
